package com.sxbbc.common.core.mapper.jz;

import com.sxbbc.common.core.entity.jz.AgAgent;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.sxbbc.common.core.dto.jz.CustomerTeamVo;
import com.sxbbc.common.core.entity.jz.CCustomer;

import java.util.List;
import java.util.Map;

/**
 * <p>
 * 会员信息表 Mapper 接口
 * </p>
 *
 * @author leehao
 * @since 2019-05-05
 */
public interface CCustomerMapper extends BaseMapper<CCustomer> {

    /**
     * 通过手机号查询用户
     *
     * @param phone 手机号
     * @return com.sxbbc.common.core.entity.jz.CCustomer
     * @author leehao
     */
    @Select("select * from c_customer where phone = ${phone}")
    CCustomer getCustomerByPhone(@Param("phone") String phone);

    /**
     * 查询时间段用户注册数量
     *
     * @param dateType
     * @param channel  注册类型
     * @return
     * @author xiaoky
     */
    int queryCustomerNumByChannelAndTime(@Param("time") String time, @Param("dateType") String dateType, @Param("channel") Integer channel);

    /**
     * 查询我的团队数据
     *
     * @param page 分页
     * @param team 查询数据
     * @return
     * @author xiaoky
     */
    IPage<CustomerTeamVo> queryMyTeamList(IPage<CustomerTeamVo> page, @Param("param") CustomerTeamVo team);

    /**
     * 统计团队人数
     *
     * @param team 查询数据
     * @return
     * @author xiaoky
     */
    int countMyTeamNum(CustomerTeamVo team);

    /**
     * 统计会员人数
     *
     * @param queryMap
     * @return
     */
    int sumCustomerNum(Map<String, Object> queryMap);

    CCustomer selectNearPeople(@Param("levelId") int levelId, @Param("list") List<Integer> list);

    int selectEffectiveCustomerNum(@Param("param") AgAgent agAgent);



    /**
     * 查询会员是否符合升级要求
     * @param parentId
     * @return
     */
    int selectCustomerUpgrade(@Param("parentId") Integer parentId);

    List<CCustomer> queryTeam();
}
